package com.mars.push.core.ctrl;

import com.mars.fw.web.reponse.King;
import com.mars.fw.web.reponse.KingCode;
import com.mars.push.api.dto.ManagePushMessageInput;
import com.mars.push.api.dto.MessageSearch;
import com.mars.push.core.entity.PushMessageEntity;
import com.mars.push.core.service.PushServiceImpl;
import com.mars.push.core.service.impl.PushMessageServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author King
 * @create 2020/5/25 14:10
 */
@Api(tags = "【VV Work】 内部使用 推送管理接口")
@RestController
@RequestMapping(value = "/api/v1/manage/push")
public class VvPushManagerController {

    @Autowired
    private PushServiceImpl pushService;

    @Autowired
    private PushMessageServiceImpl pushMessageService;

    /**
     * 通知栏消息推送
     *
     * @param input
     * @return
     */
    @ApiOperation(value = "内部用-通知栏消息推送接口")
    @PostMapping(value = "/notice")
    public King notice(@RequestBody ManagePushMessageInput input) {
        return King.success(KingCode.SUCCESS,pushService.push(input));
    }

    /**
     * 自定义消息推送
     *
     * @param input
     * @return
     */
    @ApiOperation(value = "内部用-自定义消息推送接口")
    @PostMapping(value = "/custom")
    public King custom(@RequestBody ManagePushMessageInput input) {
        return King.success(KingCode.SUCCESS,pushService.push(input));
    }


    /**
     * 消息列表
     *
     * @param search
     * @return
     */
    @ApiOperation(value = "获取消息列表")
    @PostMapping(value = "/listPushMessage")
    King<List<PushMessageEntity>> listPushMessage(@RequestBody MessageSearch search) {
        return King.success(KingCode.SUCCESS,pushMessageService.listPushMessage(search));
    }


//    @RequestMapping("/index")
//    public String index(Model model) {
//        model.addAttribute("name", "hello pillar");
//        return "index";
//    }

}
